package com.linkstec.gtjakettle;


import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.repository.kdr.KettleDatabaseRepository;
import org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta;
/**
 * 用java创建kettle资源库
 * @author lyl
 *
 */
public class KettleCreateRepositoryTest {
	/**
	 * 创建资源库。
	 * @throws KettleException
	 */
	public static void runWithDb() throws KettleException{ 
        KettleEnvironment.init();
        //创建DB资源库 
        KettleDatabaseRepository repository=new KettleDatabaseRepository(); 
        DatabaseMeta databaseMeta=new DatabaseMeta("144.51","Oracle","Native(JDBC)","10.189.144.51","GTJA","1522","kettle","kettle");
        repository.create();
        //选择资源库 
        KettleDatabaseRepositoryMeta kettleDatabaseRepositoryMeta=new KettleDatabaseRepositoryMeta("144.51","kettle","Transformation description",databaseMeta); 
        repository.init(kettleDatabaseRepositoryMeta); 
        //连接资源库 
        repository.connect("admin","admin");
   } 
	public static void main(String[] args) throws KettleException {
		runWithDb();
    }
}